use crate::src::src::hash_int::int_hash;
use crate::src::src::hash_pointer::pointer_hash;
use crate::src::src::hash_string::{string_hash, string_nocase_hash};
use crate::src::struct_and_type::UnitTestFunction;
use crate::src::test::framework::run_tests;
use :: libc;
extern "C" {}
#[no_mangle]
pub extern "C" fn test_pointer_hash() {
    let mut array: [i32; 200] = [0; 200];
    let mut i: i32 = 0;
    let mut j: i32 = 0;
    i = 0 as i32;
    while i < 200 as i32 {
        array[i as usize] = 0 as i32;
        i += 1;
        i;
    }
    i = 0 as i32;
    while i < 200 as i32 {
        j = i + 1 as i32;
        while j < 200 as i32 {
            assert!(
                pointer_hash(
                    (unsafe { &mut *array.as_mut_ptr().offset(i as isize) }) as *mut i32
                        as *mut libc::c_void,
                ) != pointer_hash(
                    (unsafe { &mut *array.as_mut_ptr().offset(j as isize) }) as *mut i32
                        as *mut libc::c_void,
                )
            );
            j += 1;
            j;
        }
        i += 1;
        i;
    }
}
#[no_mangle]
pub extern "C" fn test_int_hash() {
    let mut array: [i32; 200] = [0; 200];
    let mut i: i32 = 0;
    let mut j: i32 = 0;
    i = 0 as i32;
    while i < 200 as i32 {
        array[i as usize] = i;
        i += 1;
        i;
    }
    i = 0 as i32;
    while i < 200 as i32 {
        j = i + 1 as i32;
        while j < 200 as i32 {
            assert!(
                int_hash(
                    (unsafe { &mut *array.as_mut_ptr().offset(i as isize) }) as *mut i32
                        as *mut libc::c_void,
                ) != int_hash(
                    (unsafe { &mut *array.as_mut_ptr().offset(j as isize) }) as *mut i32
                        as *mut libc::c_void,
                )
            );
            j += 1;
            j;
        }
        i += 1;
        i;
    }
    i = 5000 as i32;
    j = 5000 as i32;
    assert!(
        int_hash(&mut i as *mut i32 as *mut libc::c_void)
            == int_hash(&mut j as *mut i32 as *mut libc::c_void)
    );
}
#[no_mangle]
pub extern "C" fn test_string_hash() {
    let mut test1: [i8; 15] =
        *(unsafe { ::core::mem::transmute::<&[u8; 15], &mut [i8; 15]>(b"this is a test\0") });
    let mut test2: [i8; 15] =
        *(unsafe { ::core::mem::transmute::<&[u8; 15], &mut [i8; 15]>(b"this is a tesu\0") });
    let mut test3: [i8; 16] =
        *(unsafe { ::core::mem::transmute::<&[u8; 16], &mut [i8; 16]>(b"this is a test \0") });
    let mut test4: [i8; 15] =
        *(unsafe { ::core::mem::transmute::<&[u8; 15], &mut [i8; 15]>(b"this is a test\0") });
    let mut test5: [i8; 15] =
        *(unsafe { ::core::mem::transmute::<&[u8; 15], &mut [i8; 15]>(b"This is a test\0") });
    assert!(
        string_hash(test1.as_mut_ptr() as *mut libc::c_void)
            != string_hash(test2.as_mut_ptr() as *mut libc::c_void)
    );
    assert!(
        string_hash(test1.as_mut_ptr() as *mut libc::c_void)
            != string_hash(test3.as_mut_ptr() as *mut libc::c_void)
    );
    assert!(
        string_hash(test1.as_mut_ptr() as *mut libc::c_void)
            != string_hash(test5.as_mut_ptr() as *mut libc::c_void)
    );
    assert!(
        string_hash(test1.as_mut_ptr() as *mut libc::c_void)
            == string_hash(test4.as_mut_ptr() as *mut libc::c_void)
    );
}
#[no_mangle]
pub extern "C" fn test_string_nocase_hash() {
    let mut test1: [i8; 15] =
        *(unsafe { ::core::mem::transmute::<&[u8; 15], &mut [i8; 15]>(b"this is a test\0") });
    let mut test2: [i8; 15] =
        *(unsafe { ::core::mem::transmute::<&[u8; 15], &mut [i8; 15]>(b"this is a tesu\0") });
    let mut test3: [i8; 16] =
        *(unsafe { ::core::mem::transmute::<&[u8; 16], &mut [i8; 16]>(b"this is a test \0") });
    let mut test4: [i8; 15] =
        *(unsafe { ::core::mem::transmute::<&[u8; 15], &mut [i8; 15]>(b"this is a test\0") });
    let mut test5: [i8; 15] =
        *(unsafe { ::core::mem::transmute::<&[u8; 15], &mut [i8; 15]>(b"This is a test\0") });
    assert!(
        string_nocase_hash(test1.as_mut_ptr() as *mut libc::c_void)
            != string_nocase_hash(test2.as_mut_ptr() as *mut libc::c_void)
    );
    assert!(
        string_nocase_hash(test1.as_mut_ptr() as *mut libc::c_void)
            != string_nocase_hash(test3.as_mut_ptr() as *mut libc::c_void)
    );
    assert!(
        string_nocase_hash(test1.as_mut_ptr() as *mut libc::c_void)
            == string_nocase_hash(test5.as_mut_ptr() as *mut libc::c_void)
    );
    assert!(
        string_nocase_hash(test1.as_mut_ptr() as *mut libc::c_void)
            == string_nocase_hash(test4.as_mut_ptr() as *mut libc::c_void)
    );
}
static mut tests_test_hash_functions: [UnitTestFunction; 5] = {
    [
        Some(test_pointer_hash as unsafe extern "C" fn() -> ()),
        Some(test_int_hash as unsafe extern "C" fn() -> ()),
        Some(test_string_hash as unsafe extern "C" fn() -> ()),
        Some(test_string_nocase_hash as unsafe extern "C" fn() -> ()),
        None,
    ]
};
fn main_0_test_hash_functions(mut _argc: i32, mut _argv: *mut *mut i8) -> i32 {
    run_tests(unsafe { tests_test_hash_functions.as_mut_ptr() });
    return 0 as i32;
}
pub fn main_test_hash_functions() {
    let mut args: Vec<*mut i8> = Vec::new();
    for arg in ::std::env::args() {
        args.push(
            (::std::ffi::CString::new(arg))
                .expect("Failed to convert argument into CString.")
                .into_raw(),
        );
    }
    args.push(::core::ptr::null_mut());
    {
        ::std::process::exit(main_0_test_hash_functions(
            (args.len() - 1) as i32,
            args.as_mut_ptr() as *mut *mut i8,
        ) as i32)
    }
}
